<template>
	<view class="sign-container">
		<view class="sign-header">
			<view class="circle-1" @click="sign()">
				<view class="circle-2">
					<view class="circle-3">
						点我签到
					</view>
				</view>

			</view>
			<view class="hongbao">
				<view class="sction-item" @click="badBag('/otherpages/member/balance_money/balance_money')">
					<text class="hongbao_bt">红包</text>
				</view>
			</view>

			<view class="rule">
				<view class="sction-item" @click="openRule">
					<text class="rule">规则</text>
				</view>
			</view>
			<!-- <view class="sign-btn" @click="sign()" :class="hasSign == 0 && isUse == 1 ? 'ns-bg-color' : ''">{{ hasSign == 1 ? '已签到' : '立即签到' }}</view> -->
		</view>
		<view class="sign-content">
			<!-- 插入模式 -->
			<uni-calendar @change="change" :date="time" :lunar="true" :selected="selected" @monthSwitch="monthSwitch" />
		</view>
		<uni-popup ref="signin" class="hongbao1">
			<view class="pay-methods">
				<image v-if="hb==true" src="../../../static/hongbao.png" @click="redPacket()" mode="widthFix"></image>
				<image v-if="hb==false" src="../../../static/hongbao_bg.png" @click="close()" mode="widthFix">
					<view v-if="hb==false" class="red_text" @click="redPacket()">
						<view class="red_text1">恭喜您获得</view>
						<view class="red_text2">{{balance}}</view>
						<view class="red_text3">已存入余额账户</view>
					</view>
				</image>
			</view>
		</uni-popup>
		<uni-popup ref="registerPopup" type="bottom">
			<view class="flex-row margin-top-sm justify-center justify-between bg-gray-1 padding-sm border-bottom-xs border-gray-4 border-solid" style="border: 0;">
				<text class="text-xl color-red-6 text-bold">{{ regisiterAgreement.title }}</text>
			</view>
			<view class="padding-x-md bg-gray-1" style="height: 600rpx;overflow-y:scroll;">
				<rich-text :nodes="regisiterAgreement.content"></rich-text>
			</view>
		</uni-popup>

	</view>
</template>
<script>
	import signIn from '../public/js/signin.js';
	import globalConfig from '@/common/js/golbalConfig.js';
	import uniPopup from '@/components/uni-popup/uni-popup.vue';

	export default {
		components: {
			uniPopup
		},
		data() {
			return {
				isIphoneX: false,
				isUse: false,
				hb: true,
				regisiterAgreement: {
					title: '',
					content: ''
				},
			};
		},
		onLoad(option) {
			this.isIphoneX = this.$util.uniappIsIPhoneX();
			if (option.back) this.back = option.back;
			if (option.redirect) this.redirect = option.redirect;
		},

		onShow() {
			this.$langConfig.refresh();
			this.init();
			this.getRgisterPopup();
		},
		mixins: [signIn, globalConfig],
		methods: {
			close() {
				this.$refs.signin.close()
			},
			// 切换红包图
			redPacket() {
				this.hb = false
			},

			ruleShow(url) {
				if (!uni.getStorageSync('token')) {
					this.$refs.login.open(url);
				} else {
					this.$util.redirectTo(url);
				}
			},
			// 展示使用规则
			openRule() {
					this.$refs.registerPopup.open();
			},
			
			// 获取使用规则
			getRgisterPopup() {
				this.$api.sendRequest({
					url: '/membersignin/api/Signin/ruleConfig',
					success: res => {
						if (res.code >= 0) {
							this.regisiterAgreement = res.data.value;
						}
					}
				});
			},
			badBag(url) {
				if (!uni.getStorageSync('token')) {
					this.$refs.login.open(url);
				} else {
					this.$util.redirectTo(url);
				}
			},
			
		}
	};
</script>
<style lang="scss">
	// 红包	
	/deep/.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
		background: none !important;
	}

	.red_text {
		position: absolute;
		top: 53%;
		left: 37%;
		display: flex;
		flex-direction: column;
		align-items: center;

		// z-index: 999;
		// position: absolute;
		// left: 50%;
		// top: 50%;
		// display: flex;
		// flex-direction: column;
		// align-items: center;
		>view {
			color: #fccf55;
		}

		.red_text1 {
			font-size: 16px;
		}

		.red_text2 {
			font-size: 25px;
		}

		.red_text3 {
			font-size: 14px;
		}
	}

	.rule {
		height: 37px;
		line-height: 37px;
		padding-left: 10px;
		width: 50px;
		font-size: 15px;
		border-top-right-radius: 25px;
		border-bottom-right-radius: 25px;
		color: #333;
		background-color: #f1f1f1;
		// float: left;
		position: absolute;
		left: 0;
	}
	.conten-box {
		width:100vw;
		padding: 0 $ns-padding $ns-padding;
		background-color: #FFFFFF !important;
		
		.title {
			line-height: 100rpx;
			font-size: $ns-font-size-lg + 4rpx;
			font-weight: bold;
			border-bottom: 2rpx solid $ns-border-color-gray;
			margin-bottom: $ns-margin;
		}
		.con {
			width: 100%;
			min-height: 600rpx;
			overflow-y: scroll;
			text-align: left;
			text-indent: 50rpx;
		}
	}

	.hongbao {
		height: 25px;
		line-height: 25px;
		padding: 8px 10px;
		padding-left: 16px;
		font-size: 16px;
		border-top-left-radius: 25px;
		border-bottom-left-radius: 25px;
		color: #333;
		background-color: #f1f1f1;
		position: absolute;
		right: 0;
	}



	uni-page-body,
	uni-page-refresh {
		height: 100%;
	}

	.iphontX-top {
		top: 1160;
	}


	.sign-btn {
		width: 448rpx;
		height: 72rpx;
		border-radius: 36rpx;
		margin-bottom: 97rpx;
		margin: 0 auto;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #d2d2d2;
	}

	.sign-header {
		height: 360rpx;
		position: relative;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		background-image: linear-gradient(to top right, #F33F40, #EE0187);

		.circle-1 {
			width: 200rpx;
			height: 200rpx;
			background-color: #F4527B;
			border-radius: 100%;
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;

			.circle-2 {
				display: flex;
				flex-direction: row;
				justify-content: center;
				align-items: center;
				width: 170rpx;
				height: 170rpx;
				background-color: #FEB7CA;
				border-radius: 100%;

				.circle-3 {
					width: 140rpx;
					height: 140rpx;
					background-color: #fff;
					border-radius: 100%;
					text-align: center;
					line-height: 140rpx;
					color: #E8ABA3;
					font-size: 24rpx;
				}
			}
		}
	}
</style>
